package unitTests;

import static org.junit.Assert.*;
import model.courtier.DAOClient;
import model.courtier.DAOFilm;
import model.courtier.DAOLocation;
import model.donnee.Client;
import model.donnee.Film;
import model.donnee.FilmLocation;

import org.junit.Before;
import org.junit.Test;

public class LocationTest {

	FilmLocation loc = null;
	Client c = new Client();
	Film f2;
	Film f[];
	
	@Before
	public void setUp() throws Exception {
		//149425
		//252866
		c = DAOClient.getClient(149425);
		Film f = DAOFilm.getFilm(252866);
		
		String date = "15/06/2014";
		loc = new FilmLocation(date, date, null, f, c);
		
	}

	@Test
	public void avantInsertLocation() {
		DAOLocation.insertLocation(loc);
		f = DAOLocation.getClientLocations(c.getIdclient());
		DAOLocation.deleteLocation(loc);
		assertEquals(f.length, 1);
	}
	
	@Test
	public void compteFilmsZero(){
		f = DAOLocation.getClientLocations(c.getIdclient());
		assertEquals(f.length, 0);
	}
	
	@Test
	public void apresInsertLocation()
	{
		DAOLocation.insertLocation(loc);
		DAOLocation.deleteLocation(loc);
		f = DAOLocation.getClientLocations(c.getIdclient());
		assertEquals(f.length, 0);
	}

}
